package cn.kgm.makeGodV2.emotion;

import java.time.LocalDateTime;

/**
 * 短期情绪:愤怒,害怕,开心,等
 *
 * @Version 1.8
 * @Author: Kappi
 * @Date: 2025-10-14 14:57
 * @Description: cn.kgm.makeGodV2.emotion.ShortTermState
 */
public class ShortTermState {
    private final EmotionalVector emotion;
    private final LocalDateTime timestamp;
    private final String trigger; // 触发事件
    private final double intensity; // 情绪强度

    public ShortTermState(EmotionalVector emotion, String trigger) {
        this.emotion = emotion;
        this.timestamp = LocalDateTime.now();
        this.trigger = trigger;
        this.intensity = calculateIntensity();
    }

    // 情绪强度（三维向量的模，归一化到0.0-100.0）
    private double calculateIntensity() {
        double magnitude = emotion.magnitude();
        // 最大可能模长为√(100²+100²+100²)=√30000≈173.2，归一化到0-100
        return (magnitude / 173.2) * 100.0;
    }

    // Getters
    public EmotionalVector getEmotion() {
        return emotion;
    }

    public LocalDateTime getTimestamp() {
        return timestamp;
    }

    public String getTrigger() {
        return trigger;
    }

    public double getIntensity() {
        return intensity;
    }
}
